<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:s="http://jboss.com/products/seam/taglib"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:a="http://richfaces.org/a4j"
    xmlns:rich="http://richfaces.org/rich"
    template="layout/template.xhtml">

<ui:define name="body">

    <h:form id="arret" styleClass="edit">

        <rich:panel>
            <f:facet name="header">#{arretHome.managed ? 'Edit' : 'Add'} Arret</f:facet>


            <s:decorate id="voyageIdVoyageField" template="layout/edit.xhtml">
                <ui:define name="label">Voyage id voyage</ui:define>
                <h:inputText id="voyageIdVoyage"
                       required="true"
                       disabled="#{arretHome.managed}"
                          value="#{arretHome.instance.id.voyageIdVoyage}">
                    <a:support event="onblur" reRender="voyageIdVoyageField" bypassUpdates="true" ajaxSingle="true"/>
                </h:inputText>
            </s:decorate>

            <s:decorate id="gareIdgareField" template="layout/edit.xhtml">
                <ui:define name="label">Gare idgare</ui:define>
                <h:inputText id="gareIdgare"
                       required="true"
                       disabled="#{arretHome.managed}"
                          value="#{arretHome.instance.id.gareIdgare}">
                    <a:support event="onblur" reRender="gareIdgareField" bypassUpdates="true" ajaxSingle="true"/>
                </h:inputText>
            </s:decorate>




            <s:decorate id="heureArriveeField" template="layout/edit.xhtml">
                <ui:define name="label">Heure arrivee</ui:define>
                <rich:calendar id="heureArrivee"
                          value="#{arretHome.instance.heureArrivee}" datePattern="MM/dd/yyyy hh:mm a"/>
            </s:decorate>


            <s:decorate id="heureDepartField" template="layout/edit.xhtml">
                <ui:define name="label">Heure depart</ui:define>
                <rich:calendar id="heureDepart"
                          value="#{arretHome.instance.heureDepart}" datePattern="MM/dd/yyyy hh:mm a"/>
            </s:decorate>

            <div style="clear:both">
                <span class="required">*</span>
                required fields
            </div>

        </rich:panel>

        <div class="actionButtons">

            <h:commandButton id="save"
                          value="Save"
                         action="#{arretHome.persist}"
                       disabled="#{!arretHome.wired}"
                       rendered="#{!arretHome.managed}"/>

            <h:commandButton id="update"
                          value="Save"
                         action="#{arretHome.update}"
                       rendered="#{arretHome.managed}"/>

            <h:commandButton id="delete"
                          value="Delete"
                         action="#{arretHome.remove}"
                      immediate="true"
                       rendered="#{arretHome.managed}"/>

            <s:button id="cancelEdit"
                   value="Cancel"
             propagation="end"
                    view="/Arret.xhtml"
                rendered="#{arretHome.managed}"/>

            <s:button id="cancelAdd"
                   value="Cancel"
             propagation="end"
                    view="/#{empty arretFrom ? 'ArretList' : arretFrom}.xhtml"
                rendered="#{!arretHome.managed}"/>

        </div>
    </h:form>

<rich:tabPanel switchType="ajax">

    <rich:tab label="Voyage *" labelClass="required">
    <div class="association" id="voyageParent">

        <h:outputText value="There is no voyage associated with this arret."
                   rendered="#{arretHome.instance.voyage == null}"/>

        <rich:dataTable var="_voyage"
                   value="#{arretHome.instance.voyage}"
                rendered="#{arretHome.instance.voyage != null}"
              rowClasses="rvgRowOne,rvgRowTwo"
                      id="voyageTable">
            <h:column>
                <f:facet name="header">Id voyage</f:facet>
                <h:outputText value="#{_voyage.idVoyage}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Train idtrain</f:facet>
                <h:outputText value="#{_voyage.train.idtrain}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Date depart</f:facet>
                <h:outputText value="#{_voyage.dateDepart}">
                    <s:convertDateTime type="both" dateStyle="short"/>
                </h:outputText>
            </h:column>
            <h:column>
                <f:facet name="header">Date arrivee</f:facet>
                <h:outputText value="#{_voyage.dateArrivee}">
                    <s:convertDateTime type="both" dateStyle="short"/>
                </h:outputText>
            </h:column>
        </rich:dataTable>

        <div class="actionButtons">
            <s:button id="#{arretHome.instance.voyage != null ? 'changeParentvoyage' : 'selectParentvoyage'}" value="#{arretHome.instance.voyage != null ? 'Change' : 'Select'} voyage"
                       view="/VoyageList.xhtml">
                <f:param name="from" value="ArretEdit"/>
            </s:button>
        </div>

    </div>
    </rich:tab>

    <rich:tab label="Gare *" labelClass="required">
    <div class="association" id="gareParent">

        <h:outputText value="There is no gare associated with this arret."
                   rendered="#{arretHome.instance.gare == null}"/>

        <rich:dataTable var="_gare"
                   value="#{arretHome.instance.gare}"
                rendered="#{arretHome.instance.gare != null}"
              rowClasses="rvgRowOne,rvgRowTwo"
                      id="gareTable">
            <h:column>
                <f:facet name="header">Idgare</f:facet>
                <h:outputText value="#{_gare.idgare}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Ville</f:facet>
                <h:outputText value="#{_gare.ville}"/>
            </h:column>
        </rich:dataTable>

        <div class="actionButtons">
            <s:button id="#{arretHome.instance.gare != null ? 'changeParentgare' : 'selectParentgare'}" value="#{arretHome.instance.gare != null ? 'Change' : 'Select'} gare"
                       view="/GareList.xhtml">
                <f:param name="from" value="ArretEdit"/>
            </s:button>
        </div>

    </div>
    </rich:tab>
</rich:tabPanel>
</ui:define>

</ui:composition>
